home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / stonehenge / Stone.h < prev    next >
C/C++ Source or Header  |  1996-11-11  |  3KB  |  99 lines

  1. /*
  2.  * (c) Copyright 1993, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for
  6.  * any purpose and without fee is hereby granted, provided that the above
  7.  * copyright notice appear in all copies and that both the copyright notice
  8.  * and this permission notice appear in supporting documentation, and that
  9.  * the name of Silicon Graphics, Inc. not be used in advertising
  10.  * or publicity pertaining to distribution of the software without specific,
  11.  * written prior permission.
  12.  *
  13.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  14.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  16.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  17.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  18.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  19.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  20.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  21.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  22.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  23.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  24.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  25.  *
  26.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  27.  * Use, duplication, or disclosure by the Government is subject to
  28.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  29.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  30.  * clause at DFARS 252.227-7013 and/or in similar or successor
  31.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  32.  * Unpublished-- rights reserved under the copyright laws of the
  33.  * United States.  Contractor/manufacturer is Silicon Graphics,
  34.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  35.  *
  36.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  37.  */
  38. #ifndef STONE_H
  39. #define STONE_H
  40.  
  41. #include "Color.h"
  42. #include "Point.h"
  43.  
  44. class Stone {
  45.  public:
  46.   Stone();
  47.   ~Stone();
  48.   Stone operator=(Stone a);
  49.  
  50.   void set_dimensions(GLfloat x, GLfloat y, GLfloat z);
  51.   void set_dimensions(Point p);
  52.   Point get_dimensions() {return dimensions;};
  53.  
  54.   /* p = 0 --> sharp corners, p == 1 --> completely rounded corners */
  55.   void erode(float p);
  56.   float get_erosion() {return erosion;};
  57.  
  58.   void translate(GLfloat x, GLfloat y, GLfloat z);
  59.   void translate(Point p);
  60.  
  61.   /* Angle in degrees */
  62.   void rotate_self_aboutz(GLfloat angle);
  63.  
  64.   void draw();
  65.  
  66.   void draw_shadow(Point dlight);
  67.   void draw_shadow(Point dlight, GLfloat blur, Color color, Color diffuse);
  68.  
  69.  private:
  70.   Point translation;
  71.   GLfloat rotation;
  72.   /* dimensions contains the length, width, and height of the stone */
  73.   Point dimensions;
  74.  
  75.   GLfloat erosion;
  76.  
  77.   Point points[24];
  78.   int points_valid;
  79.   void compute_points();
  80.  
  81.   int transforms_valid;
  82.   inline Point trans_rot_point(Point p, float c, float s);
  83.   inline Point transform_point(Point p, float c, float s);
  84.   void transform_points();
  85.   
  86.   void draw_faces(int flat = 0);
  87.   void draw_faces(Point *p, int flat = 0);
  88.  
  89.   void draw_edges(int flat = 0);
  90.   void draw_edges(Point *p, int flat = 0);
  91.   void draw_edge(Point n1, Point n2, Point *p, int a, int b, int c, int d,
  92.          int flat = 0);
  93.  
  94.   void draw_corners(int flat = 0) {draw_corners(points, flat);};
  95.   void draw_corners(Point *p, int flat = 0);
  96. };
  97.  
  98. #endif
  99.